<template>
  <DIV class="bg_write" v-loading="loading" style="width: 250px">
    <div class="receipt">
      <div class="receipt_title">
        <p>{{adminTitle}}</p>
        <p v-if="base.sid>0">
          {{base.shop_title}}
          <span
            v-if="base.shop_province && base.shop_province !=''"
          >（{{$fnc.deleteNumber(`${base.shop_province || ''}${base.shop_city || ''}${base.shop_area || ''}${base.shop_town || ''}`)+base.shop_address}}）</span>
        </p>
      </div>
      <p>--{{base.is_pay==1 ?'已在线支付':'未支付'}}--</p>
      <div class="receipt_info">
        <p>下单时间：{{base.created_time |getTimeFormat}}</p>
        <p>订单编号：{{base.oid}}</p>
        <p>会员昵称：{{base.uid_nickname || base.uid_cn }}</p>
        <p
          v-if="base.tid_username && base.tid_username!=''"
        >推荐人:{{base.tid_nickname || base.tid_username || ''}}</p>
      </div>
      <div class="receipt_shop">
        <div class="receipt_shop_item" v-for="(shop,s) in product_ar " :key="s">
          <p>{{shop.title}}</p>
          <p>
            <span v-for="(vo,index) in shop.sku_cn" :key="index">{{vo}} &nbsp;&nbsp;&nbsp;&nbsp;</span>
          </p>
          <p>
            <span>x{{ shop.number }}</span>
            <span>{{ shop.price |keepTwoNum }}</span>
          </p>
        </div>
      </div>
      <div class="receipt_price">
        <p v-if="base.is_integral == '1' && Number(base.integral_dk_money) != 0">
          积分抵用：
          <span>-{{base.integral_dk_money |keepTwoNum}}</span>
        </p>
        <p v-if="base.is_red == '1' && Number(base.red_money    ) != 0 ">
          优惠卷抵用：
          <span>-{{base.red_money |keepTwoNum}}</span>
        </p>
        <p class="pay_money">
          实付：
          <span>￥{{base.money | keepTwoNum}}元</span>
        </p>
      </div>
      <div class="receipt_address">
        <p>{{base.mail_name}}（{{base.mail_tel}}）</p>
        <p>{{$fnc.deleteNumber(base.mail_province+base.mail_city+base.mail_area+base.mail_town)}}{{base.mail_address}}</p>
        <p
          v-if="base.status != '未支付' && base.remarks && base.remarks != ''&& base.remarks != '[]'"
        >用户备注：{{base.remarks}}</p>
      </div>
      <p class="receipt_end">******** 完 ********</p>
    </div>
  </DIV>
</template>
<script>
export default {
  data() {
    return {
      adminTitle: "",
      options: this.$addressJson,
      selectedOptions: [],
      optionProps: {
        value: "y",
        label: "t",
        children: "z"
      },
      show: false,
      loading: false,
      dialogVisible: false,
      data: {
        province: "",
        city: "",
        area: "",
        town: ""
      },
      base: {
        id: "",
        oid: "",
        uid: "",
        uid_cn: "",
        sid: "",
        money: "",
        product_money: "",
        mail_money: "",
        pay: "",
        is_pay: "0",
        is_virtual: "0",
        status: "",
        integral_reach: "",
        integral_exchange: "",
        mail_name: "",
        mail_tel: "",
        mail_province: "",
        mail_city: "",
        mail_area: "",
        mail_town: "",
        mail_address: "",
        mail_courier: "",
        mail_id: "",
        mail_oid: "",
        mail_time: "",
        remark: "",
        admin_remark: "",
        created_time: "",
        pay_time: "",
        complete_time: "",
        update_time: ""
      },
      product_ar: [],
      other: []
    };
  },
  components: {},
  methods: {
    objectSpanMethod({ row, column, rowIndex, columnIndex }) {
      if (columnIndex === 5) {
        if (rowIndex % 2 === 0) {
          return {
            rowspan: 2,
            colspan: 1
          };
        } else {
          return {
            rowspan: 0,
            colspan: 0
          };
        }
      } else if (columnIndex === 6) {
        if (rowIndex % 2 === 0) {
          return {
            rowspan: 2,
            colspan: 1
          };
        } else {
          return {
            rowspan: 0,
            colspan: 0
          };
        }
      }
    },

    getDetails(id) {
      console.log(id);
      var data = {};
      data["id"] = id;
      this.$api.getUser.getOrderInfo(data).then(res => {
        console.log(res.data.result);

        this.base = res.data.result.base;
        if (this.base.pay_time) {
          this.base.pay_time = this.$fnc.vuetime(this.base.pay_time);
        }
        if (this.base.mail_time) {
          this.base.mail_time = this.$fnc.vuetime(this.base.mail_time);
        }
        if (this.base.complete_time) {
          this.base.complete_time = this.$fnc.vuetime(this.base.complete_time);
        }

        this.product_ar = res.data.result.product_ar;
        this.selectedOptions = [
          this.base.mail_province,
          this.base.mail_city,
          this.base.mail_area
        ];
        if (this.base.mail_town) {
          this.selectedOptions.push(this.base.mail_town);
        }
        this.other = res.data.result.other;
        console.log(this.selectedOptions);
      });
    }
  },

  beforeCreate() {
    this.loading = true; //数据未加载之前调用loading
  },
  created() {
    this.loading = false;
    this.$api.getPage.getindex({ iden: "home" }).then(res => {
      this.adminTitle = res.data.result.head;
    });
  },
  computed: {},
  watch: {},
  mounted() {
    console.log(this.$store.state.adminTitle);
    this.getDetails(this.$route.query.id);
  }
};
</script>

<style lang="less" scoped>
body {
  height: auto;
}
body,
td {
  height: auto;
  font-size: 13px;
}

// .info{
//    margin-left:20px;
// }

// .info li{
//     // display: inline-block;
//     float: left;
//     width: 30%;
//     margin:10px 5px 5px 0;
// }
// .box{
//     margin-left:20px;
//     margin-right:20px;
//     margin-top:50px;
// }
// .count{
//     line-height: 40px;
// }
.receipt {
  width: 100%;
  display: flex;
  flex-flow: column;
  padding: 30px 10px;
  font-size: 12px;
  .receipt_title {
    width: 100%;
    > p:nth-of-type(1) {
      font-size: 24px;
      font-weight: bold;
      line-height: 50px;
    }
    > p {
      text-align: center;
    }
  }
  > p {
    font-size: 18px;
    font-weight: 500;
    padding: 10px 0;
  }
  .receipt_info {
    width: 100%;
    padding: 10px 0;
    border-top: 1px dashed #000000;
    border-bottom: 1px dashed #000000;
    display: flex;
    flex-flow: column;
    justify-content: flex-start;
    align-items: flex-start;
    p {
      line-height: 20px;
    }
  }
  .receipt_shop {
    width: 100%;
    padding: 10px 0;
    border-bottom: 1px dashed #000000;
    .receipt_shop_item {
      width: 100%;
      display: flex;
      flex-flow: column;
      justify-content: flex-start;
      align-items: flex-start;
      padding: 5px 0;
      border-bottom: 1px dashed #eeeeee;

      p {
        width: 100%;
      }
      p:nth-of-type(1) {
        text-align: left;
        font-size: 14px;
        font-weight: bold;
        padding-bottom: 5px;
      }
      p:nth-of-type(2) {
        text-align: left;
        font-size: 12px;
        font-weight: 400;
        padding-bottom: 10px;
      }
      p:nth-of-type(3) {
        text-align: right;
        font-weight: bold;
        display: flex;
        flex-wrap: nowrap;
        justify-content: space-between;
        align-items: center;
        span:nth-of-type(1) {
          font-size: 12px;
        }
        span:nth-of-type(2) {
          font-size: 16px;
        }
      }
    }
  }
  .receipt_price {
    width: 100%;
    padding: 10px 0;
    border-bottom: 1px dashed #000000;
    display: flex;
    flex-flow: column;
    justify-content: flex-start;
    align-items: flex-start;
    p {
      width: 100%;
      text-align: left;
      line-height: 20px;
      span {
        font-weight: bold;
      }
    }
    .pay_money {
      font-size: 16px;
      font-weight: bold;
      padding-top: 15px;
      span {
        font-weight: bold;
      }
    }
  }
  .receipt_address {
    width: 100%;
    padding: 10px 0;
    p {
      width: 100%;
      text-align: left;
      line-height: 20px;
    }
  }
  .receipt_end {
    width: 100%;
    padding-top: 20px;
    text-align: center;
    height: 24px;
    line-height: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
  }
}
</style>
